package org.ben.xintoucloud.javase.collection;

import java.util.*;

/**
 * @Author: Ben
 * @Date: 2019/7/11 10:04
 */
public class Test {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入学生学号");
        String number=scanner.next();
        System.out.println("请输入学生姓名");
        String name=scanner.next();
        System.out.println("请输入学生年龄");
        int age=scanner.nextInt();
        System.out.println("请输入学生班级");
        String className=scanner.next();
        System.out.println("请输入学生年级");
        String gradeName=scanner.next();
        HashMap<String,Student> hashMap=new HashMap<>();
        hashMap.put(number,new Student(name,age,number,className,gradeName));
        if (hashMap.containsValue(number)){
            System.out.println(hashMap.get(number).toString());
        }else {
            System.out.println("查无此人");
        }

        System.out.println("------------------------------------------------------------------------------");
        System.out.println("请输入商品id：");
        int id=scanner.nextInt();
        System.out.println("请输入商品名称：");
        String storeName=scanner.next();
        System.out.println("请输入商品价格：");
        int price=scanner.nextInt();
        HashSet<Store> hashSet=new HashSet<>();
        ArrayList<Store> arrayList=new ArrayList<>();
        hashSet.add(new Store(storeName,price,id));
        Iterator<Store> iterator=hashSet.iterator();
        while (iterator.hasNext()){
            Store store=iterator.next();
            arrayList.add(store);
            System.out.println(store.toString());
        }
    }
}
